{% extends "restricted/base.html" %}
{% load nm %}
{% load js %}

{% block head_resources %}
{{block.super}}
{% jsinclude "nm" %}
<style type="text/css">
.errorlist { color: red; }
</style>
{% endblock %}

{% block content %}

<h1>Edit fingerprints for {{person.fullname}}</h1>

<form action="{% url 'fprs_person_list' key=person.lookup_key %}" method="post">{% csrf_token %}
  {% for hidden in form.hidden_fields %} {{hidden}} {% endfor %}
  {{ form.non_field_errors }}
  {% for f in form.visible_fields %}
    <p>{{f.label_tag}}<br>{{f}}<br><small>{{f.help_text}}</small></p>{{f.errors}}
  {% endfor %}
  <input type="submit" value="Add key">
</form>

<table>
  <thead>
    <tr>
      <th>Key</th>
      <th>SC/DFSG/DMUP agreement</th>
      <th>Active</th>
      <th>Actions</th>
    </tr>
  </thead>
  <tbody>
  {% for fpr in person.fprs.all %}
  <tr>
      <td>{{fpr.fpr|fingerprint}}</td>
      <td>
        {% if "edit_statements" in visit_perms %}
        <a href="{% url 'fprs_agreement_edit' key=person.lookup_key fpr=fpr.fpr %}">{{fpr.agreement_status}}</a>
        {% elif "see_statements" in visit_perms %}
        <a href="{% url 'fprs_agreement_show' key=person.lookup_key fpr=fpr.fpr %}">{{fpr.agreement_status}}</a>
        {% endif %}
        </a>
      </td>
      <td>{{fpr.is_active}}</td>
      <td>
        {% if not fpr_is_active %}
        <form action="{% url 'fprs_person_activate' key=person.lookup_key fpr=fpr.fpr %}" method="POST">{% csrf_token %}
          <button type="submit">Activate</button>
        </form>
        {% endif %}
      </td>
  </tr>
  {% endfor %}
  </tbody>
</table>

{% endblock %}

